package com.zk.nakedfowl.powerManager.dao;

import com.zk.nakedfowl.powerManager.pojo.Menu;
import com.zk.nakedfowl.powerManager.pojo.RoleMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface RoleMenuDao extends JpaRepository<RoleMenu,String>,JpaSpecificationExecutor<RoleMenu>{
    @Query(value = "select * from sys_role_menu where userId=?1;",nativeQuery = true)
    List<RoleMenu> findByMenuId(String MenuId);
    @Query(value = "select * from sys_role_menu where roleId=?1;",nativeQuery = true)
    List<RoleMenu> findByRoleId(String roleId);

    @Query(value = "select id,parentId,name,sort,href,target,icon,isShow,permission from sys_role_menu,sys_menu " +
            "where sys_role_menu.menuId=sys_menu.id and roleId=?1 order by sort;",nativeQuery = true)
    List<Menu> findMenusByRoleId(String roleId);
}
